package org.example;

import java.util.Arrays;

public class Test1 {
    //leetcode 179 最大数 https://leetcode.cn/problems/largest-number/description/
    public String largestNumber(int[] nums) {
        String[] strs = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strs[i] = "" + nums[i];
        }
        Arrays.sort(strs,(a, b) -> {
            return (b + a).compareTo(a + b);
        });
        StringBuilder sb = new StringBuilder();
        for (String s : strs) sb.append(s);
        if (sb.charAt(0) == '0') return "0";
        return sb.toString();
    }
}
